import { axios } from '@/utils/request'

export function layoutConfigList (parameter) {
  return axios({
    url: '/layout/config/list',
    method: 'post',
    data: parameter
  })
}
export function layoutModuleList (parameter = {}) {
  return axios({
    url: '/layout/module/list',
    method: 'post',
    data: parameter
  })
}
export function layoutPageList (parameter = {}) {
  return axios({
    url: '/layout/page/list',
    method: 'post',
    data: parameter
  })
}
export function layoutModuleInfo (parameter = {}) {
  return axios({
    url: '/layout/module/info',
    method: 'post',
    data: parameter
  })
}
/**
 * 编辑模版
 * @param {*} data
 * @returns
 */
export function laychModuleUpdate (data = {}) {
  return axios({
    url: '/layout/module/update',
    method: 'post',
    data
  })
}
/**
 * 活动内容列表
 * @param {*} data
 * @returns
 */
export function layoutAcivityConfigList (data = {}) {
  const type = data.code == 'rwzx_hyrw' ? 'config-scene-activity' : 'config'
  return axios({
    url: `/layout/${type}/list`,
    method: 'post',
    data
  })
}
/**
 * 修改模块状态  启用 未启用
 * @param {*} data
 * @returns
 */
export function layoutChangeState (data = {}, type = 'module') {
  return axios({
    url: `/layout/${type}/change/state`,
    method: 'post',
    data
  })
}
/**
 * 新增/编辑
 * @param {*} data
 * @returns
 */
export function LayoutAction (data) {
  return axios({
    url: `/layout/${data.id ? 'update' : 'add'}/module/config`,
    data,
    method: 'post',
  })
}
/**
 * 模块配置活动内容激活、暂停、重启
 * @param {*} data
 * @returns
 */
export function fetchLayoutAction (data = {}, type = 'activation') {
  return axios({
    url: `/layout/${type}/module/config`,
    data,
    method: 'post',
  })
}
/**
 * 删除场景营销和布局活动内容关联关系
 * @param {*} data
 * @returns
 */
export function fetchLayoutActivityDel (data = {}) {
  return axios({
    url: '/layout/delete/config-scene-activity',
    data,
    method: 'post',
  })
}

/**
 *
 * 优惠劵 / 商品 排序
 * @export
 * @param {*} [data={}]
 * @param {string} [type='product']
 * @return {*}
 */
export function fetchLayoutSort (data = {}) {
  return axios({
    url: '/layout/module/sort',
    data,
    method: 'post',
  })
}

/**
 * h5活动列表
 * @param {*} data
 * @returns
 */
export function activityH5List (data = {}) {
  return axios({ url: '/coupon/admin/activity/h5/list', data, method: 'post' })
}
/**
 * 删除活动组件
 * @param {*} data
 * @param {*} id
 * @returns
 */
export function activityH5Del (id) {
  return axios({ url: `/coupon/admin/activity/h5/delete/layout/${id}`, data: {}, method: 'post' })
}

/**
 * 保存表单
 * @param {*} url
 * @param {*} data
 * @returns
 */
export function saveForm (data = {}) {
  return axios({ method: 'post', url: '/coupon/admin/form/edit/form', data })
}

// 参与明细
export function getPartakeCollect (data = {}) {
  return axios({ method: 'post', url: '/coupon/admin/form/partake/collect', data })
}

// 表单汇总
export function getFormSum (data = {}) {
  return axios({ method: 'post', url: '/coupon/admin/form/sum', data })
}

// 获取填写内容
export function getWriteCollect (data = {}) {
  return axios({ method: 'post', url: '/coupon/admin/form/write/collect', data })
}

// 获取填写占比
export function getWriteProportion (data = {}) {
  return axios({ method: 'post', url: '/coupon/admin/form/write/proportion', data })
}
/**
 * 活动基本数据回显
 * @param {*} data
 * @returns
 */
export function couponActivityH5Query (id, data = {}) {
  return axios({ url: `/coupon/admin/activity/h5/query/${id}`, data, method: 'post' })
}
/**
 * 新增或修改活动配置组件
 * @param {*} data
 * @returns
 */
export function couponActivityH5Layout (data = {}) {
  return axios({ url: '/coupon/admin/activity/h5/add/layout', data, method: 'post' })
}
/**
 * 活动基础信息新增
 * @param {*} data
 * @returns
 */
export function couponActivityH5Add (data = {}) {
  return axios({ url: `/coupon/admin/activity/h5/${data.id ? 'update' : 'add'}`, data, method: 'post' })
}

/**
 * 活动基础信息编辑
 * @param {*} data
 * @returns
 */
export function couponActivityH5Update (data = {}) {
  return axios({ url: '/coupon/admin/activity/h5/update', data, method: 'post' })
}

/**
 * 活动暂停
 * @param {*} data
 * @returns
 */
export function couponActivityH5Suspend (data = {}, type) {
  return axios({ url: `/coupon/admin/activity/h5/${type}`, data, method: 'post' })
}

/**
 * 活动批量激活 / 活动批量暂停
 * @param {*} data
 * @param {*} type
 * @returns
 */
export function couponActivityH5Batch (data = {}, type = 'activation') {
  return axios({ url: `/coupon/admin/activity/h5/batch/${type}`, data, method: 'post' })
}

/**
 * 删除活动组件
 * @param {*} data
 * @param {*} id
 * @returns
 */
export function couponActivityH5DelLayout (id) {
  return axios({ url: `/coupon/admin/activity/h5/delete/layout/${id}`, data: {}, method: 'post' })
}

/**
 * 删除活动
 * @param {*} data
 * @param {*} id
 * @returns
 */
export function couponActivityH5Del (data = {}) {
  return axios({ url: '/coupon/admin/activity/h5/delete', data, method: 'post' })
}
/**
 * 根据活动id查询活动组件列表
 * @param {*} data
 * @param {*} id
 * @returns
 */
export function couponActivityH5QueryLayout (id) {
  return axios({ url: `/coupon/admin/activity/h5/query/layout/${id}`, data: {}, method: 'post' })
}
/**
 * 活动领券明细
 * @param {*} data
 * @returns
 */
export function couponActivityH5QueryList(data = {}) {
  return axios({ url: "/coupon/admin/activity/h5/coupon/list", data, method: 'post' });
}
/**
 * 活动数据统计
 * @param {*} data
 * @returns
 */
export function couponActivityH5Count(data = {}) {
  return axios({ url: "/coupon/admin/activity/h5/count", data, method: 'post' });
}